﻿--病人的电子申请单信息存在Patient_ApplicationSheet表中
DECLARE @Var_PatientId VARCHAR(20);
SET @Var_PatientId = @PatientId_In;

--根据病人最近一次就诊的门诊号往前推天
SELECT  MZNum AS MZNum,
        PatientName AS PatientName, 
        KSName AS DeptName,
        YSName AS DocotName,
        RegisterDate AS ProcessDate
FROM    dbo.MZRegisterSheet(NOLOCK)
WHERE   PatientID = @Var_PatientId
        AND DelDate IS NULL
		AND RegisterDate > (SELECT TOP 1 RegisterDate FROM dbo.MZRegisterSheet(NOLOCK) ORDER BY RegisterDate DESC ) - 90  
ORDER BY RegisterDate DESC;
